/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package designpattern.creational_patterns;

/**
 *
 * @author anh_yeu_em_nhieu_lam
 */
public class FactoryMethodPattern {
    interface Display{
        public void display();
    }
    class DiemKhongMau implements Display{
        public void display() {
            System.out.print("Day la diem khong mau\n");
        }
    }
    class DiemCoMau implements Display{
        public void display() {
           System.out.print("Day la diem co mau\n"); 
        }
    }
    class InCacDiem{
        private String _loai;
        private Display _display = null;
        public InCacDiem(String loai) {
            this._loai = loai;
        }
        public Display paint(){
            if(_loai.equals("khongmau")){
                _display = new DiemKhongMau();
            }else if(_loai.equals("comau")){
                _display = new DiemCoMau();
            }
            return _display;
        }
    }
    public static void main(String[] args){
        new FactoryMethodPattern().new InCacDiem("khongmau").paint().display();
        new FactoryMethodPattern().new InCacDiem("comau").paint().display();
    }
}
/*
Day la diem khong mau
Day la diem co mau
 * */